package code;

/**
 * @author noob
 * @version 1.0
 * @date 2021/3/19 13:24
 */
public class ShellSort2 {

    public ShellSort2() {
    }


    public static <E extends Comparable<E>> void sort(E[] data){

        int h = data.length /2;

        while (h >=1){



                //从地h给元素开始--混着处理
                for (int i = h; i < data.length; i++) {
                    E   t = data[i];
                    int j;
                    for ( j = i; j - h >=0 && t.compareTo(data[j-h]) < 0 ; j-=h) {
                        data[j]=data[j-h];
                    }
                    data[j] = t;
                }


            h /= 2;
        }

    }
}
